# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=vivisect
pkgver=v1.2.1.r5.gf0934976
_pyver=3.13
pkgrel=1
epoch=3
groups=('blackarch' 'blackarch-debugger' 'blackarch-disassembler'
        'blackarch-reversing')
pkgdesc='A Python based static analysis and reverse engineering framework.'
arch=('any')
url='https://github.com/vivisect/vivisect'
license=('BSD')
depends=('python' 'python-pyasn1' 'python-pyasn1-modules' 'python-cxxfilt'
         'python-msgpack' 'python-pycparser' 'python-pyqt5'
         'python-pyqt5-webengine')
makedepends=('git' 'python-build' 'python-pip')
source=("git+https://github.com/$pkgname/$pkgname.git")
options=('!emptydirs')
sha512sums=('SKIP')

prepare() {
  cd $pkgname

  #sed -i 's/==/>=/' setup.py
  ## https://github.com/vivisect/vivisect/issues/623
  #sed -i 's/cxxfilt>=0.2.1,<0.3.0/cxxfilt>=0.2.1/' setup.py
}

pkgver() {
  cd $pkgname

  git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
}

build() {
  cd $pkgname

  python -m build --wheel --outdir="$startdir/dist"
}

package() {
  cd $pkgname

	pip install \
    --verbose \
    --disable-pip-version-check \
    --no-warn-script-location \
    --ignore-installed \
    --no-compile \
    --no-deps \
    --root="$pkgdir" \
    --prefix=/usr \
    --no-index \
    --find-links="file://$startdir/dist" \
    $pkgname

  sed -i 's/f"u/"u/' \
    "$pkgdir/usr/lib/python$_pyver/site-packages/vivisect/__init__.py"

  rm -rf "$pkgdir/usr/lib/python$_pyver/site-packages/vstruct/"
}

